//
//  TDDiyShowCalehdaCell.m
//  TBRentClient
//
//  Created by tonbright on 2018/6/9.
//  Copyright © 2018年 tonbright. All rights reserved.
//

#import "TDDiyShowCalehdaCell.h"
#import "UIView+ZLExtension.h"

@implementation TDDiyShowCalehdaCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UIImageView *xieXianImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"斜线右"]];
        xieXianImageView.frame = CGRectMake(0, 0, 23, 23);
        xieXianImageView.zl_centerX = self.contentView.zl_centerX;
        xieXianImageView.zl_centerY = self.contentView.zl_centerX;
        [self.contentView insertSubview:xieXianImageView atIndex:0];
        self.xieXianImageView = xieXianImageView;
        
    }
    return self;
}

- (void)setIsCanUse:(BOOL)isCanUse {
    _isCanUse = isCanUse;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _xieXianImageView.frame = CGRectMake(0, 0, 23, 23);
    _xieXianImageView.zl_centerX = self.titleLabel.zl_centerX;
    _xieXianImageView.zl_centerY = self.titleLabel.zl_centerY;
    
    if (self.selIndex == 0) {
        if (!_isCanUse) {
            self.titleLabel.textColor = [UIColor lightGrayColor];
            self.userInteractionEnabled = NO;
            _xieXianImageView.hidden = NO;
            self.titleLabel.font = [UIFont systemFontOfSize:13.5];
        }else {
            if (_isCanPick) {
                self.userInteractionEnabled = YES;
                _xieXianImageView.hidden = YES;
                self.titleLabel.font = [UIFont boldSystemFontOfSize:13.5];
                self.titleLabel.textColor = [UIColor blackColor];
            }else {
                self.userInteractionEnabled = NO;
                _xieXianImageView.hidden = YES;
                self.titleLabel.font = [UIFont boldSystemFontOfSize:13.5];
                self.titleLabel.textColor = [UIColor lightGrayColor];
            }
        }
    }else {
        if (!_isCanUse) {
            self.titleLabel.textColor = [UIColor lightGrayColor];
            self.userInteractionEnabled = NO;
            _xieXianImageView.hidden = NO;
            self.titleLabel.font = [UIFont systemFontOfSize:13.5];
        }else {
            if (_isCanReturn) {
                self.userInteractionEnabled = YES;
                _xieXianImageView.hidden = YES;
                self.titleLabel.font = [UIFont boldSystemFontOfSize:13.5];
                self.titleLabel.textColor = [UIColor blackColor];
            }else {
                self.userInteractionEnabled = NO;
                _xieXianImageView.hidden = YES;
                self.titleLabel.font = [UIFont boldSystemFontOfSize:13.5];
                self.titleLabel.textColor = [UIColor lightGrayColor];
            }
        }
    }
    self.titleLabel.highlightedTextColor = [UIColor whiteColor];
    
    
//    if (!_isCanUse) {
//        self.titleLabel.textColor = [UIColor lightGrayColor];
//        self.userInteractionEnabled = NO;
//        _xieXianImageView.hidden = NO;
//        self.titleLabel.font = [UIFont systemFontOfSize:13.5];
//    }
//    //可用时候隐藏侧滑线-------
//    else {
//        self.userInteractionEnabled = YES;
//        _xieXianImageView.hidden = YES;
//        self.titleLabel.font = [UIFont boldSystemFontOfSize:13.5];
//    }
}


@end
